﻿Imports CRM.BusinessLayer
Imports System.Data
Imports System.ComponentModel

Partial Public Class frmAdminSMSTemplates

    Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnAddNew.Click
        lstBookmarks.IsEnabled = True
        btnSave.Content = "Save New"
        btnSave.IsEnabled = True
        btnEdit.IsEnabled = False
        txtBody.IsReadOnly = False
    End Sub

    Private Sub frmAdminSMSTemplates_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        Try
            GeneralTasks.ChangeTheme(Me)
            GeneralTasks.EnumerateandFill(Me.LogicalChildren)
            LoadCombo()
            BindTemplateList()
            BindBookMarkList()

        Catch ex As Exception
        Finally

        End Try
    End Sub
    Private Sub lstTemplates_SelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles lstTemplates.SelectionChanged

        Dim myInfo As Admin.TemplateInfo
        Try
            If Me.lstTemplates.SelectedItems.Count = 0 Then
                Exit Sub
            Else
                btnEdit.IsEnabled = True
            End If
            myInfo = Admin.GetSMSTemplate(Me.lstTemplates.SelectedItem(0).ToString)

            With myInfo
                Me.txtBody.Text = .Body
                Me.txtTemplateName.Text = .TemplateName
            End With
        Catch ex As Exception
        Finally
            myInfo = Nothing
        End Try
    End Sub

    Private Sub LoadCombo()
        With Me.cboBranch
            .SelectedValuePath = "Branch_ID"
            .DisplayMemberPath = "Branch_Name"
            .ItemsSource = CType(CommonDataFunctions.BranchList, IListSource).GetList
            .SelectedValue = GlobalCRM.CurrentBranchId
        End With
    End Sub
    Private Sub BindTemplateList()
        Dim myData As DataTable
        myData = Admin.SMSTemplateList(cboBranch.SelectedValue)
    End Sub
    Private Sub BindBookMarkList()
        Dim myData As DataTable
        myData = Admin.BookmarkList
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnSave.Click

    End Sub
End Class
